package com.siao.example.libaray
{
	import com.greensock.TweenMax;
	import com.siao.applications.Application;
	import com.siao.applications.ApplicationManager;
	import com.siao.applications.Module;
	import com.siao.core.FlashPlayer;
	import com.siao.display.LayoutElement;
	import com.siao.example.common.ui.Layer;
	import com.siao.example.libaray.main.state.LibarayMainState;
	
	/**
	 * 示例程序
	 * @author SiaoLeon
	 */
	public class Libaray extends Application
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		/**
		 * 主模块
		 */
		public var main:Module;
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function Libaray()
		{
			super();
			
			this.main = new Module(new LibarayMainState());
			this.addModule(this.main);
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		override public function startup():void
		{
			this.addChild(Layer.instance.background);
			this.addChild(Layer.instance.content);
			this.addChild(Layer.instance.foreground);
			this.addChild(Layer.instance.popup);
			this.addChild(Layer.instance.dialog);
			this.addChild(Layer.instance.tooltip);
			
			FlashPlayer.RegisterRightClickHandler(onRightClick);
		}
		
		// -------------------------------------------------------------------------------------------------------- 函数
		
		private function onRightClick():void
		{
			var element:LayoutElement = new LayoutElement();
			element.draw(0XFFFFFF, 1);
			ApplicationManager.instance.stage.addChild(element);
			TweenMax.to(element, 0.5, {alpha: 0, onComplete: function():void {element.remove();}});
		}
	
	}
}
